package com.myccb.app.view.investment;

import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;

import com.myccb.app.base.BaseActivity;
import com.myccb.app.R;
import com.myccb.app.widget.CommonToolBar;

public class TargetsActivity extends BaseActivity {
    private int[][] imgs = {
            {R.mipmap.chart1_investment, R.mipmap.chart1_investment, R.mipmap.chart1_investment},
            {R.mipmap.chart2_investment, R.mipmap.chart2_investment, R.mipmap.chart2_investment},
            {R.mipmap.chart1_investment, R.mipmap.chart2_investment, R.mipmap.chart1_investment}
            };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_targets_investment);

        CommonToolBar commonToolBar=findViewById(R.id.common_toolbar);
        Toolbar toolbar=commonToolBar.getToolbar();
        setSupportActionBar(toolbar);
        commonToolBar.setTitle("基金详情");

        commonToolBar.setOnLeftButtonClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.slide_out_right);
            }
        });

        int position = getIntent().getExtras().getInt("position");
        Intent intent = new Intent(this, DialogActivity.class);
        startActivity(intent);

        Template1 template1 = new Template1();
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        LinearLayout linearLayout = findViewById(R.id.rootLinearLayout_targetsActivity);
        if (linearLayout.getChildCount() <= 0) {
            fragmentTransaction.add(R.id.rootLinearLayout_targetsActivity, template1)
                    .commit();
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        RadioGroup radioGroup = findViewById(R.id.radioGroup1);
        final ImageView imageView = findViewById(R.id.image_center_investment);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.button11:
                        imageView.setImageResource(imgs[0][0]);
                        break;
                    case R.id.button12:
                        imageView.setImageResource(imgs[1][0]);
                        break;
                    case R.id.button13:
                        imageView.setImageResource(imgs[2][0]);
                        break;
                }
            }
        });
    }

}
